1
|
|
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
package org.apache.geronimo.ews.ws4j2ee.module;
|
18
|
|
|
19
|
|
import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
|
20
|
|
|
21
|
|
import java.io.File;
|
22
|
|
import java.io.FileInputStream;
|
23
|
|
import java.io.FileNotFoundException;
|
24
|
|
import java.io.InputStream;
|
25
|
|
import java.net.MalformedURLException;
|
26
|
|
import java.net.URL;
|
27
|
|
import java.net.URLClassLoader;
|
28
|
|
import java.util.ArrayList;
|
29
|
|
|
30
|
|
|
31
|
|
|
32
|
|
|
33
|
|
public class DirModule implements Module {
|
34
|
|
protected InputStream wscfFile;
|
35
|
|
protected InputStream webddfile;
|
36
|
|
protected InputStream ejbJarfile;
|
37
|
|
private String location;
|
38
|
|
private ClassLoader parentCL;
|
39
|
|
|
40
|
|
|
41
|
|
|
42
|
|
|
43
|
|
|
44
|
0
|
public DirModule(String location, ClassLoader parentCL)
|
45
|
|
throws GenerationFault {
|
46
|
0
|
File file = null;
|
47
|
0
|
this.parentCL = parentCL;
|
48
|
0
|
this.location = location;
|
49
|
0
|
try {
|
50
|
0
|
file = new File(location + "/WEB-INF/webservices.xml");
|
51
|
0
|
if (file.exists()) {
|
52
|
0
|
wscfFile = new FileInputStream(file);
|
53
|
|
} else {
|
54
|
0
|
file = new File(location + "/META-INF/webservices.xml");
|
55
|
0
|
if (file.exists()) {
|
56
|
0
|
wscfFile = new FileInputStream(file);
|
57
|
|
} else {
|
58
|
0
|
wscfFile = new FileInputStream(new File(location + "/webservices.xml"));
|
59
|
|
}
|
60
|
|
}
|
61
|
0
|
findDDs();
|
62
|
|
} catch (FileNotFoundException e) {
|
63
|
0
|
e.printStackTrace();
|
64
|
0
|
throw GenerationFault.createGenerationFault(e);
|
65
|
|
}
|
66
|
|
}
|
67
|
|
|
68
|
|
|
69
|
|
|
70
|
|
|
71
|
|
|
72
|
3
|
public DirModule(File wscfDDFile)
|
73
|
|
throws GenerationFault {
|
74
|
3
|
try {
|
75
|
3
|
wscfFile = new FileInputStream(wscfDDFile);
|
76
|
3
|
File parent = wscfDDFile.getParentFile();
|
77
|
3
|
String parentName = parent.getAbsolutePath();
|
78
|
3
|
if (parentName.endsWith("WEB-INF")
|
79
|
|
|| parentName.endsWith("WEB-INF/")
|
80
|
|
|| parentName.endsWith("WEB-INF")
|
81
|
|
|| parentName.endsWith("META-INF/")) {
|
82
|
0
|
this.location = parent.getParentFile().getAbsolutePath();
|
83
|
|
} else {
|
84
|
3
|
this.location = parent.getAbsolutePath();
|
85
|
|
}
|
86
|
3
|
findDDs();
|
87
|
|
} catch (FileNotFoundException e) {
|
88
|
0
|
e.printStackTrace();
|
89
|
0
|
throw GenerationFault.createGenerationFault(e);
|
90
|
|
}
|
91
|
|
}
|
92
|
|
|
93
|
3
|
public void findDDs() throws GenerationFault {
|
94
|
3
|
try {
|
95
|
3
|
File file = new File(location + "/META-INF/ejb-jar.xml");
|
96
|
3
|
if (file.exists()) {
|
97
|
0
|
ejbJarfile = new FileInputStream(file);
|
98
|
|
} else {
|
99
|
3
|
file = new File(location + "/ejb-jar.xml");
|
100
|
3
|
if (file.exists()) {
|
101
|
3
|
ejbJarfile = new FileInputStream(file);
|
102
|
|
}
|
103
|
|
}
|
104
|
3
|
file = new File(location + "WEB-INF/web.xml");
|
105
|
3
|
if (file.exists()) {
|
106
|
0
|
webddfile = new FileInputStream(file);
|
107
|
|
} else {
|
108
|
3
|
file = new File(location + "/web.xml");
|
109
|
3
|
if (file.exists()) {
|
110
|
3
|
webddfile = new FileInputStream(file);
|
111
|
|
}
|
112
|
|
}
|
113
|
3
|
if (wscfFile == null)
|
114
|
0
|
throw new GenerationFault("wscf file must not be null");
|
115
|
|
} catch (FileNotFoundException e) {
|
116
|
0
|
e.printStackTrace();
|
117
|
0
|
throw GenerationFault.createGenerationFault(e);
|
118
|
|
}
|
119
|
|
}
|
120
|
|
|
121
|
3
|
public ClassLoader getClassLoaderWithPackageLoaded() throws GenerationFault {
|
122
|
3
|
try {
|
123
|
3
|
File file = new File(location);
|
124
|
3
|
return new URLClassLoader(new URL[]{file.toURL()}, parentCL);
|
125
|
|
} catch (MalformedURLException e) {
|
126
|
0
|
e.printStackTrace();
|
127
|
0
|
throw GenerationFault.createGenerationFault(e);
|
128
|
|
}
|
129
|
|
}
|
130
|
|
|
131
|
3
|
public ArrayList getClassPathElements() throws GenerationFault {
|
132
|
3
|
ArrayList elements = new ArrayList();
|
133
|
3
|
elements.add(new File(location));
|
134
|
3
|
return elements;
|
135
|
|
}
|
136
|
|
|
137
|
3
|
public InputStream getEjbJarfile() throws GenerationFault {
|
138
|
3
|
return ejbJarfile;
|
139
|
|
}
|
140
|
|
|
141
|
3
|
public InputStream getWebddfile() throws GenerationFault {
|
142
|
3
|
return webddfile;
|
143
|
|
}
|
144
|
|
|
145
|
3
|
public InputStream getWscfFile() throws GenerationFault {
|
146
|
3
|
return wscfFile;
|
147
|
|
}
|
148
|
|
|
149
|
0
|
public void setEjbJarfile(InputStream stream) throws GenerationFault {
|
150
|
0
|
this.ejbJarfile = stream;
|
151
|
|
}
|
152
|
|
|
153
|
0
|
public void setWebddfile(InputStream stream) throws GenerationFault {
|
154
|
0
|
this.webddfile = stream;
|
155
|
|
}
|
156
|
|
|
157
|
0
|
public void setWscfFile(InputStream stream) throws GenerationFault {
|
158
|
0
|
this.wscfFile = stream;
|
159
|
|
}
|
160
|
|
|
161
|
|
|
162
|
|
|
163
|
|
|
164
|
3
|
public InputStream findFileInModule(String path) throws GenerationFault {
|
165
|
3
|
try {
|
166
|
3
|
File file = new File(location + "/" + path);
|
167
|
3
|
if (file.exists())
|
168
|
0
|
new FileInputStream(file);
|
169
|
3
|
return null;
|
170
|
|
} catch (FileNotFoundException e) {
|
171
|
0
|
e.printStackTrace();
|
172
|
0
|
throw GenerationFault.createGenerationFault(e);
|
173
|
|
}
|
174
|
|
}
|
175
|
|
|
176
|
|
}
|
177
|
|
|